#include <iostream>
#include <cmath>
using namespace std;
struct street{
    int n;int m;int L;int V;
};
struct car{
    int d;
    int v;
    int a;
};
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    for(int u=0;u<T;u++){
    street S;
    cin>>S.n>>S.m>>S.L>>S.V;
    car cars[S.n];
    for(int i=0;i<S.n;i++){
        cin>>cars[i].d>>cars[i].v>>cars[i].a;
    }
    int p[S.m],dp[S.m]={};
    for(int i=0;i<S.m;i++){
        cin>>p[i];
    }
    int c=0,c2=0;
    for(int i=0;i<S.n;i++){
        for(int j=0;j<S.m;j++){
            double s=sqrt(cars[i].v*cars[i].v+2*cars[i].a*(p[j]-cars[i].d));
            if(s>S.V){
                c++;
                c++;
                dp[j]=1;
                break;
            }
        }
    }
    cout<<c-1<<" ";
    for(int j=0;j<S.m;j++){
        c2+=dp[j];
    }cout<<c2+1;
    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15*/
